package org.zxp.thread.base;

import org.junit.Test;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @program: zxp-thread-test
 * @description: ${description}
 * @author: X-Pacific zhang
 * @create: 2019-05-07 12:15
 **/
public class ThreadOth {
    @Test
    public void testInner() throws InterruptedException {
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("i am ThreadInner");
            }
        }).start();
        Thread.sleep(1000);
    }

    @Test
    public void testLamda() throws InterruptedException {
        new Thread(() -> System.out.println("i am Lamda")).start();
        Thread.sleep(1000);
    }

    @Test
    public void testThreadPool() throws InterruptedException {
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        executorService.execute(() -> System.out.println("i am ThreadPool"));
        Thread.sleep(1000);
    }
}
